
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- Apple devices fullscreen -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- Apple devices fullscreen -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<link href="../css/main.css?v=12u234y" rel="stylesheet" type="text/css">
<link href="../css/page.css" rel="stylesheet" type="text/css">
<link href="../font/css/font-awesome.min.css" rel="stylesheet" />
<!--[if IE 7]>
  <link rel="stylesheet" href="../font/css/font-awesome-ie7.min.css">
<![endif]-->
<link href="../js/jquery-ui/jquery-ui.min.css" rel="stylesheet" type="text/css"/>
<link href="../js/perfect-scrollbar.min.css" rel="stylesheet" type="text/css"/>
<style type="text/css">html, body { overflow: visible;}</style>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/jquery-ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="../js/layer/layer.js"></script><!-- 弹窗js 参考文档 http://layer.layui.com/-->
<script type="text/javascript" src="../js/admin.js"></script>
<script type="text/javascript" src="../js/flexigrid.js"></script>
<script type="text/javascript" src="../js/jquery.validation.min.js"></script>
<script type="text/javascript" src="../js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="../js/jquery.mousewheel.js"></script>
<script src="../js/myFormValidate.js"></script>
<script src="../js/myAjax2.js"></script>
<script src="../js/global.js"></script>
<script type="text/javascript">
function delfunc(obj){
	layer.confirm('确认删除？', {
		  btn: ['确定','取消'] //按钮
		}, function(){
			$.ajax({
				type : 'post',
				url : $(obj).attr('data-url'),
				data : {act:'del',del_id:$(obj).attr('data-id')},
				dataType : 'json',
				success : function(data){
					if(data==1){
						layer.msg('操作成功', {icon: 1});
						$(obj).parent().parent().parent().remove();
					}else{
						layer.msg(data, {icon: 2,time: 2000});
					}
				}
			})
		}, function(index){
			layer.close(index);
			return false;// 取消
		}
	);
}

function delAll(obj,name){
	var a = [];
	$('input[name*='+name+']').each(function(i,o){
		if($(o).is(':checked')){
			a.push($(o).val());
		}
	})
	if(a.length == 0){
		layer.alert('请选择删除项', {icon: 2});
		return;
	}
	layer.confirm('确认删除？', {btn: ['确定','取消'] }, function(){
			$.ajax({
				type : 'get',
				url : $(obj).attr('data-url'),
				data : {act:'del',del_id:a},
				dataType : 'json',
				success : function(data){
					if(data == 1){
						layer.msg('操作成功', {icon: 1});
						$('input[name*='+name+']').each(function(i,o){
							if($(o).is(':checked')){
								$(o).parent().parent().remove();
							}
						})
					}else{
						layer.msg(data, {icon: 2,time: 2000});
					}
					layer.closeAll();
				}
			})
		}, function(index){
			layer.close(index);
			return false;// 取消
		}
	);	
}

//表格列表全选反选
$(document).ready(function(){
	$('.hDivBox .sign').click(function(){
	    var sign = $('#flexigrid > table>tbody>tr');
	   if($(this).parent().hasClass('trSelected')){
	       sign.each(function(){
	           $(this).removeClass('trSelected');
	       });
	       $(this).parent().removeClass('trSelected');
	   }else{
	       sign.each(function(){
	           $(this).addClass('trSelected');
	       });
	       $(this).parent().addClass('trSelected');
	   }
	})
});

//获取选中项
function getSelected(){
	var selectobj = $('.trSelected');
	var selectval = [];
    if(selectobj.length > 0){
        selectobj.each(function(){
        	selectval.push($(this).attr('data-id'));
        });
    }
    return selectval;
}
</script>
</head>
<body style="background-color: #FFF; overflow: auto;">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
            <div class="subject">
                <h3>短信配置模板 - 编辑模板</h3>
                <h5>网站系统短信配置模板管理</h5>
            </div>
        </div>
    </div>
    <form class="form-horizontal" id="addEditSmsTemplate" method="post">
        <input type="hidden" name="tpl_id" value="">
        <div class="ncap-form-default">
            <dl class="row">
                <dt class="tit">
                    <label for="sms_sign"><em>*</em>短信签名</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="" name="sms_sign" id="sms_sign" class="input-txt">
                    <span class="err" id="err_sms_sign" style="display:none;">短信签名不能为空 </span>
                    <p class="notic">必须与阿里大鱼短信签名一致</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="sms_tpl_code"><em>*</em>短信模板ID</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="" name="sms_tpl_code" id="sms_tpl_code" class="input-txt">
                    <span id="err_sms_tpl_code" class="err" style="display:none;">短信模板ID不能为空</span>
                    <p class="notic">必须与阿里大鱼短信模板ID一致</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="send_scene"><em>*</em>发送场景</label>
                </dt>
                <dd class="opt">
                                            <select  class="small form-control" name="send_scene" id="send_scene" onchange="changeContent(this.value);">
                            <option value="-1">请选择使用场景</option>
                                                            <option value="1" >用户注册</option>
                                                            <option value="2" >用户找回密码</option>
                                                            <option value="3" >客户下单</option>
                                                            <option value="4" >客户支付</option>
                                                            <option value="5" >商家发货</option>
                                                            <option value="6" >身份验证</option>
                                                    </select>
                        <span class="err" id="err_send_scene" style="display:none;">请选择使用场景</span>
                                        <span class="err"></span>
                    <p class="notic">使用场景</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="tpl_content"><em>*</em>短信内容</label>
                </dt>
                <dd class="opt">
                    <textarea id="tpl_content" name="tpl_content" class="tarea" rows="6"></textarea>
                    <span class="err" id="err_tpl_content" style="display:none;">短信内容不能为空</span>
                    <p class="notic"></p>
                </dd>
            </dl>
            <div class="bot"><a href="JavaScript:void(0);" onclick="checkForm();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a></div>
        </div>
    </form>
</div>
<script type="text/javascript">
    function changeContent(scene){
        if(scene == -1){
            $("#addEditSmsTemplate").find("textarea[name='tpl_content']").val('');
            return;
        }
        var scenes = {"1":["\u7528\u6237\u6ce8\u518c","\u9a8c\u8bc1\u7801${code}\uff0c\u60a8\u6b63\u5728\u6ce8\u518c\u6210\u4e3a${product}\u7528\u6237\uff0c\u611f\u8c22\u60a8\u7684\u652f\u6301!","regis_sms_enable"],"2":["\u7528\u6237\u627e\u56de\u5bc6\u7801","\u9a8c\u8bc1\u7801${code}\uff0c\u7528\u4e8e\u5bc6\u7801\u627e\u56de\uff0c\u5982\u975e\u672c\u4eba\u64cd\u4f5c\uff0c\u8bf7\u53ca\u65f6\u68c0\u67e5\u8d26\u6237\u5b89\u5168","forget_pwd_sms_enable"],"3":["\u5ba2\u6237\u4e0b\u5355","\u60a8\u6709\u65b0\u8ba2\u5355\uff0c\u6536\u8d27\u4eba\uff1a${consignee}\uff0c\u8054\u7cfb\u65b9\u5f0f\uff1a${phone}\uff0c\u8bf7\u60a8\u53ca\u65f6\u67e5\u6536.","order_add_sms_enable"],"4":["\u5ba2\u6237\u652f\u4ed8","\u8ba2\u5355:${order_sn}\u5df2\u7ecf\u652f\u4ed8\uff0c\u8bf7\u53ca\u65f6\u53d1\u8d27.","order_pay_sms_enable"],"5":["\u5546\u5bb6\u53d1\u8d27","\u5c0a\u656c\u7684${user_name}\u7528\u6237\uff0c\u60a8\u7684\u8ba2\u5355${order_sn}\u5df2\u53d1\u8d27\uff0c\u6536\u8d27\u4eba${consignee}\uff0c\u8bf7\u60a8\u53ca\u65f6\u67e5\u6536","order_shipping_sms_enable"],"6":["\u8eab\u4efd\u9a8c\u8bc1","\u3010${user_name}\u3011 \u5c0a\u656c\u7684\u7528\u6237\uff0c\u60a8\u7684\u9a8c\u8bc1\u7801\u4e3a${code}, \u672c\u9a8c\u8bc1\u7801\u6709\u6548\u65f6\u95f4\u4e3a10\u5206\u949f, \u8bf7\u52ff\u544a\u8bc9\u4ed6\u4eba.","bind_mobile_sms_enable"]};//Array //""{"1":["\u7528\u6237\u6ce8\u518c","\u9a8c\u8bc1\u7801${code}\uff0c\u60a8\u6b63\u5728\u6ce8\u518c\u6210\u4e3a${product}\u7528\u6237\uff0c\u611f\u8c22\u60a8\u7684\u652f\u6301!","regis_sms_enable"],"2":["\u7528\u6237\u627e\u56de\u5bc6\u7801","\u9a8c\u8bc1\u7801${code}\uff0c\u7528\u4e8e\u5bc6\u7801\u627e\u56de\uff0c\u5982\u975e\u672c\u4eba\u64cd\u4f5c\uff0c\u8bf7\u53ca\u65f6\u68c0\u67e5\u8d26\u6237\u5b89\u5168","forget_pwd_sms_enable"],"3":["\u5ba2\u6237\u4e0b\u5355","\u60a8\u6709\u65b0\u8ba2\u5355\uff0c\u6536\u8d27\u4eba\uff1a${consignee}\uff0c\u8054\u7cfb\u65b9\u5f0f\uff1a${phone}\uff0c\u8bf7\u60a8\u53ca\u65f6\u67e5\u6536.","order_add_sms_enable"],"4":["\u5ba2\u6237\u652f\u4ed8","\u8ba2\u5355:${order_sn}\u5df2\u7ecf\u652f\u4ed8\uff0c\u8bf7\u53ca\u65f6\u53d1\u8d27.","order_pay_sms_enable"],"5":["\u5546\u5bb6\u53d1\u8d27","\u5c0a\u656c\u7684${user_name}\u7528\u6237\uff0c\u60a8\u7684\u8ba2\u5355${order_sn}\u5df2\u53d1\u8d27\uff0c\u6536\u8d27\u4eba${consignee}\uff0c\u8bf7\u60a8\u53ca\u65f6\u67e5\u6536","order_shipping_sms_enable"],"6":["\u8eab\u4efd\u9a8c\u8bc1","\u3010${user_name}\u3011 \u5c0a\u656c\u7684\u7528\u6237\uff0c\u60a8\u7684\u9a8c\u8bc1\u7801\u4e3a${code}, \u672c\u9a8c\u8bc1\u7801\u6709\u6548\u65f6\u95f4\u4e3a10\u5206\u949f, \u8bf7\u52ff\u544a\u8bc9\u4ed6\u4eba.","bind_mobile_sms_enable"]};
        var txt = scenes[scene][1];

        $("#addEditSmsTemplate").find("textarea[name='tpl_content']").val(txt);
    }
    // 判断输入框是否为空
    function checkForm(){

        var smsSign = $("#addEditSmsTemplate").find("input[name='sms_sign']").val();					//短信签名
        var smsTplCode = $("#addEditSmsTemplate").find("input[name='sms_tpl_code']").val();		//模板ID
        var tplContent = $("#addEditSmsTemplate").find("textarea[name='tpl_content']").val();			//模板内容

        var sendscene = $("#send_scene option:selected").val();
        if($.trim(smsSign) == '')
        {
            $("#err_sms_sign").show();
            return false;
        }

        if($.trim(smsTplCode) == '')
        {
            $("#err_sms_tpl_code").show();
            return false;
        }

        if($.trim(tplContent) == '')
        {
            $("#err_tpl_content").show();
            return false;
        }

        if(sendscene == -1){
            $("#err_send_scene").show();
            return false;
        }
        $('#addEditSmsTemplate').submit();
    }
</script>
</body>
</html>